package com.cb.common.util;

import java.util.Date;
import java.util.GregorianCalendar;

import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;

public class DateUtil {

	public static XMLGregorianCalendar convertToXMLGregorianCalendar(Date date) {

	        GregorianCalendar cal = new GregorianCalendar();
	        cal.setTime(date);
	        XMLGregorianCalendar gc = null;
	        try {
	            gc = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
	        } catch (DatatypeConfigurationException e) {
	        	 throw new IllegalStateException("There are some error for convert java.util.Date to XMLGregorianCalendar");
	        }
	        return gc;
	    }

}
